The U.S. Census Bureau collects and distributes data under a handful of different programs. Two of the more commonly used programs are the Decennial Census and the American Community Survey (ACS). The Decennial Census is a definitely source of demographic data but only is collected every ten years. The ACS is a program that provides data estimates on a one,three, and five year timeline; ACS data is collected more frequently but the data estimates have a margin of error that must considered. While the Decennial Census only includes basic demographic data such as number of households and total population, the ACS includes many more data points that relate to transportation, income, and housing. Both the Decennial and ACS datasets have similiar data structures. Each row in both datasets include a particular variable and a number the indicates the total number of households or persons that define that variable.
nv_acs <- get_acs(geography = "tract", year=2016,
variables = "B01003_001",
state = "NV", county=c("Washoe", "Douglas")) %>%
mutate(data_source="2016 ACS 2016 5-year Estimate")
ca_acs <- get_acs(geography = "tract", year=2016,
variables = "B01003_001",
state = "CA",county=c("El Dorado", "Placer")) %>%
mutate(data_source="2016 ACS 2016 5-year Estimate")
ca_decen <- get_decennial(geography="tract", variables= c("H001001", "P001001"),
state= "CA", year= 2010, county=c("El Dorado", "Placer")) %>%
rename(estimate=value) %>% mutate(moe=0, data_source="2010 Decennial Census")
nv_decen <- get_decennial(geography="tract", variables= c("H001001", "P001001"),
state= "NV", year= 2010, county=c("Washoe", "Douglas")) %>%
rename(estimate=value) %>% mutate(moe=0, data_source="2010 Decennial Census")
all<- bind_rows(nv_decen,ca_decen, ca_acs, nv_acs) %>%
left_join(data.frame(tract), by="GEOID") %>%
filter(!is.na(STATEFP)) %>%
group_by(variable, data_source) %>% summarise(total=sum(estimate), moe=sum(moe)) %>%
mutate(variable_name = case_when (variable== "H001001" ~ "Housing Units",
variable== "P001001" ~ "Total Population",
variable== "B01003_001" ~ "Total Population"))
datatable(all, extensions = 'Buttons',
rownames=F,options=list(pageLength = 15, dom = 'Bfrtip',buttons = c('csv','pdf'),
columnDefs = list(list(className = 'dt-center', targets = 0:1))),
class = 'cell-border stripe')work_transport <- c(Drive= "B08301_002",
Walk= "B08301_019",
Bike = "B08301_018",
`Public Transport` = "B08301_010",
`Work from Home` = "B08301_021",
Other = "B08301_020",
Motorcycle = "B08301_017",
Taxi = "B08301_016")
nv <- get_acs(geography = "tract", year=2016,
variables = work_transport,
state = "NV", geometry = TRUE, summary_var = "B08301_001" )
ca <- get_acs(geography = "tract", year=2016,
variables = work_transport, summary_var = "B08301_001",
state = "CA", geometry= TRUE)
all<- rbind(nv, ca) %>%
left_join(data.frame(tract), by="GEOID") %>%
filter(!is.na(STATEFP)) %>%
dplyr::select(GEOID, NAME.x, variable, estimate, moe, summary_est, summary_moe, County) %>%
data.frame() %>% select(-geometry.x) %>%
mutate(source="2016 ACS 2016 5-year Estimate") %>%
group_by(variable) %>% summarise(number= sum(estimate), total=sum(summary_est))
datatable(all, extensions = 'Buttons',
rownames=F,options=list(pageLength = 15, dom = 'Bfrtip',buttons = c('csv','pdf'),
columnDefs = list(list(className = 'dt-center', targets = 0:1))),
class = 'cell-border stripe')hhsize<- c(`Household Size - 1 Person`="H013002",
`Household Size - 2 Person`= "H013003",
`Household Size - 3 Person`="H013004",
`Household Size - 4 Person`= "H013005",
`Household Size - 5 Person`= "H013006",
`Household Size - 6 Person` = "H013007",
`Household Size - 7 Person or More` = "H013008")
nv <- get_decennial(geography = "tract", year=2010,
variables = hhsize, county=c("Washoe", "Douglas"),
state = "NV", geometry = F, summary_var = "H013001" )
ca <- get_decennial(geography = "tract", year=2010, county=c("El Dorado", "Placer"),
variables = hhsize, summary_var = "H013001",
state = "CA", geometry= F)
all<- bind_rows(nv, ca) %>%
left_join(data.frame(tract), by="GEOID") %>%
filter(!is.na(STATEFP)) %>%
dplyr::select(GEOID, NAME.x, variable, value, County, summary_value) %>%
data.frame() %>%
mutate(data_source="2010 Decennial Census") %>%
group_by(variable, data_source) %>% summarise(number=sum(value), total=sum(summary_value))
datatable(all, extensions = 'Buttons',
rownames=F,options=list(pageLength = 15, dom = 'Bfrtip',buttons = c('csv','pdf'),
columnDefs = list(list(className = 'dt-center', targets = 0:1))),
class = 'cell-border stripe')Search through the list below to determine which variable(s) you want to analyze. You can download all of the variables
Search through the list below to determine which variable(s) you want to analyze.